package cn.zhb.backend.utils;

import lombok.Builder;
import lombok.Data;

import java.io.Serializable;

/***
 *@Description
 *@Author ZHB
 *@Create 2025/5/11 下午3:55
 **/
@Data
@Builder
public class Result<T> implements Serializable {

    private Integer code;
    private String message;
    private T data;

    public static <T> Result<T> success(T data) {
        return Result.<T>builder()
                .code(20000)
                .message("success")
                .data(data)
                .build();
    }

    public static <T> Result<T> success() {
        return Result.<T>builder()
                .code(20000)
                .message("success")
                .build();
    }

    public static <T> Result<T> error(String message) {
        return Result.<T>builder()
                .code(9999)
                .message(message)
                .build();
    }

    @Override
    public String toString() {
        return "Result{" +
                "code=" + code +
                ", messsage='" + message + '\'' +
                ", data=" + data +
                '}';
    }
}
